package com.wyzz.hr.util.tags;

import com.opensymphony.xwork2.util.ValueStack;
import java.util.ArrayList;
import java.util.List;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.apache.axis.utils.StringUtils;
import org.apache.struts2.components.UIBean;

public class TableHeadComp extends UIBean {
	class Table {

		public String getTrName() {
			return trName;
		}

		public void setTrName(String trName) {
			this.trName = trName;
		}

		public String getOrderName() {
			return orderName;
		}

		public void setOrderName(String orderName) {
			this.orderName = orderName;
		}

		public String getOrder() {
			return order;
		}

		public void setOrder(String order) {
			this.order = order;
		}

		private String trName;
		private String orderName;
		private String order;
	}

	public TableHeadComp(ValueStack stack, HttpServletRequest request,
			HttpServletResponse response) {
		super(stack, request, response);
	}

	protected String getDefaultTemplate() {
		return "tablehead";
	}

	protected void evaluateExtraParams() {
		super.evaluateExtraParams();
		if (StringUtils.isEmpty(headName))
			return;
		String array[] = headName.trim().split(";");
		if (array.length == 0)
			return;
		headList = new ArrayList();
		String arr$[] = array;
		int len$ = arr$.length;
		for (int i$ = 0; i$ < len$; i$++) {
			String value = arr$[i$];
			String head[] = value.split("-");
			Table table = new Table();
			if (StringUtils.isEmpty(head[0]))
				table.setOrderName("noOrder");
			else
				table.setOrderName(head[0].trim());
			if (head.length > 2)
				table.setOrder(head[2].trim());
			table.setTrName(head[1].trim());
			headList.add(table);
		}

		addParameter("headList", headList);
		addParameter("orderForm", orderForm);
		if (checkBox != null)
			addParameter("checkBox", checkBox);
	}

	public String getHeadName() {
		return headName;
	}

	public void setHeadName(String headName) {
		this.headName = headName;
	}

	public String getOrderForm() {
		return orderForm;
	}

	public void setOrderForm(String orderForm) {
		this.orderForm = orderForm;
	}

	public List getHeadList() {
		return headList;
	}

	public void setHeadList(List headList) {
		this.headList = headList;
	}

	public String getCheckBox() {
		return checkBox;
	}

	public void setCheckBox(String checkBox) {
		this.checkBox = checkBox;
	}

	public final String TEMPLATE = "tablehead";
	public String headName;
	public String orderForm;
	public List headList;
	public final String NOORDER = "noOrder";
	public String checkBox;
}
